import sys
import os
sys.path.append( os.getcwd() )
from wellfunctions import WellFunctions
import datetime
import cProfile
import random

def profile_wua_calculate():
    wf = WellFunctions(gen=True)
    tt=[]
    for cont in range(0,20):
        u=10*random.random()
        a=2.5*random.random()
        tstart=datetime.datetime.now()
        val=wf.wua_from_dictionary(u=u, a=a)
        tt.append((datetime.datetime.now()-tstart))
        print "I%s (u: %f,a: %f,wua: %f, t: %s)" % (cont,u,a,val,tt[cont])
    sum = 0
    for t in tt:
        sum = sum + float(t.microseconds)
        media=sum/20.0/1000000
    print "Tiempo medio por llamada es de %f segundos." % media
    
if __name__ == '__main__':
    print "WellFunctios calculate wua"
    cProfile.run('profile_wua_calculate()')
